﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Smartec.Accounts.Camel.AMS.Model.Entities;

namespace Smartec.Accounts.Camel.AMS.Model.Repository
{
//    class DBAuditRepository
//    {
//    }
//}
    internal static class NewsRepository
    {

        internal static void AddNews(News news)
        {
            AMSObjectContextHelper.CurrentObjectContext.News.AddObject(news);
        }
        internal static void Save()
        {
            AMSObjectContextHelper.CurrentObjectContext.SaveChanges();
        }
       
        internal static List<News> All()
        {
          return  AMSObjectContextHelper.CurrentObjectContext.News.ToList();
        }

        internal static void DeleteNewsById(int id)
        {
            var news = AMSObjectContextHelper.CurrentObjectContext.News.FirstOrDefault(t => t.ID == id);
            if (news != null)
            {
                AMSObjectContextHelper.CurrentObjectContext.News.DeleteObject(news);
            }
        }
    }
}
